package com.isoft.demo01.service.impl;

import com.isoft.demo01.dao.GameTypeDao;
import com.isoft.demo01.entity.GameType;
import com.isoft.demo01.service.GameTypeService;
import com.isoft.demo01.util.IdUtil;
import com.isoft.demo01.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service("gameTypeServiceSys")
public class GameTypeImplService implements GameTypeService {
    @Autowired
    GameTypeDao gameTypeDao;
    @Override
    public boolean insert(String typename) {
       if (typename==null){
           return false;
       }if (StringUtil.isEmpty(typename)){
           return false;
        }
       return gameTypeDao.insert(typename)>0 ;
    }

    @Override
    public List<GameType> getAll(Boolean isdel) {
        return gameTypeDao.getAll(null);
    }

    @Override
    public boolean updetadel(Integer typeid, Boolean isdel) {
        if (!IdUtil.idcheck(typeid)){
            return false;
        }
        int del=0;
        if (isdel!=null && isdel){
            del=1;
        }
        return gameTypeDao.updetadel(typeid,del)>0;
    }

    @Override
    public boolean update(Integer typeid, String typename) {
        if (!IdUtil.idcheck(typeid)){
            return false;
        }if (StringUtil.isEmpty(typename)){
            return false;
        }
        return gameTypeDao.update(typeid, typename)>0;
    }

}
